<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tt_mmk2</title>
  <meta name="keywords" content="tt_mmk2">
  <meta name="description" content="DMRG/Krylov matrix-by-matrix multiplication">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">exp</a> &gt; tt_mmk2.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/exp&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>tt_mmk2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>DMRG/Krylov matrix-by-matrix multiplication</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [ttm12] = tt_mmk2(ttm1, ttm2, eps, max_r, max_swp) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">DMRG/Krylov matrix-by-matrix multiplication 
   [TTM12] = TT_MMK2(TTM1, TTM2, EPS, [MAX_R, MAX_SWP]) 
   Computes DMRG/Krylov matrix-by-matrix multiplication with accuracy EPS.
   It just calls the MVK2 code. Uses TT1.0, so it syntax will change in
   the next release


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@qtt_tucker/kron.html" class="code" title="function [c] = kron(a,b)">kron</a>	Kronecker product of two QTT_Tuckers</li><li><a href="../../tt2/@tt_matrix/kron.html" class="code" title="function [c] = kron(a,b)">kron</a>	Kronecker product of two TT-matrices</li><li><a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>	Mode sizes of the TT-matrix</li><li><a href="../../tt2/@tt_tensor/kron.html" class="code" title="function [c] = kron(a,b)">kron</a>	Kronecker product of two TT-tensors</li><li><a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>	Reshape of the TT-tensor</li><li><a href="../../tt2/@tt_tensor/size.html" class="code" title="function [sz] = size(tt,dim)">size</a>	Mode sizes of the TT-tensor</li><li><a href="../../tt2/core/tt_mat_to_vec.html" class="code" title="function [tt_vec]=tt_mat_to_vec(tt_mat)">tt_mat_to_vec</a>	Flattens TT-matrix into TT-vector in the TT1.0 format</li><li><a href="../../tt2/core/tt_mvk2.html" class="code" title="function [y,swp]=tt_mvk2(a,x,eps, max_r, max_swp)">tt_mvk2</a>	Matrix-by-vector product by DMRG/Krylov method</li><li><a href="../../tt2/core/tt_vec_to_mat.html" class="code" title="function [tt_mat]=tt_vec_to_mat(tt_vec,n,m)">tt_vec_to_mat</a>	Converts TT-vector to TT-matrix in TT1.0 format</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="tt_minres_selfprec.html" class="code" title="function [X]=tt_minres_selfprec(A, tol, eps, maxit, prec_type)">tt_minres_selfprec</a>	Computation of the approximate TT-matrix inverse using self-prec method</li><li><a href="tt_minres_selfprec2.html" class="code" title="function [X]=tt_minres_selfprec2(A,  eps, varargin)">tt_minres_selfprec2</a>	Computation of the approximate TT-matrix inverse using self-prec method</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [ttm12] = tt_mmk2(ttm1, ttm2, eps, max_r, max_swp)</a>
0002 <span class="comment">%DMRG/Krylov matrix-by-matrix multiplication</span>
0003 <span class="comment">%   [TTM12] = TT_MMK2(TTM1, TTM2, EPS, [MAX_R, MAX_SWP])</span>
0004 <span class="comment">%   Computes DMRG/Krylov matrix-by-matrix multiplication with accuracy EPS.</span>
0005 <span class="comment">%   It just calls the MVK2 code. Uses TT1.0, so it syntax will change in</span>
0006 <span class="comment">%   the next release</span>
0007 <span class="comment">%</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0012 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0013 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0016 <span class="comment">%ivan.oseledets@gmail.com</span>
0017 <span class="comment">%---------------------------</span>
0018 
0019 d = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm1, 1);
0020 
0021 exists_max_r=1;
0022 <span class="keyword">if</span> ((nargin&lt;4)||(isempty(max_r)))
0023     exists_max_r=0;
0024 <span class="keyword">end</span>;
0025 exists_max_swp=1;
0026 <span class="keyword">if</span> ((nargin&lt;5)||(isempty(max_swp)))
0027     exists_max_swp=0;
0028 <span class="keyword">end</span>;
0029 
0030 ttmm1 = cell(d,1);
0031 
0032 ns1 = zeros(d,1);
0033 ns2 = zeros(d,1);
0034 
0035 <span class="keyword">for</span> q=1:d
0036     n1 = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm1{q},1);
0037     m = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm1{q},2);
0038     n2 = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm2{q},2);
0039     r1 = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm1{q}, 3);
0040     r2 = <a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(ttm1{q}, 4);
0041     ns1(q)=n1;
0042     ns2(q)=n2;
0043     
0044     I = eye(n2);
0045     ttmm1{q}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ttm1{q}, n1, m*r1*r2);
0046     ttmm1{q}=<a href="../../tt2/@qtt_tucker/kron.html" class="code" title="function [c] = kron(a,b)">kron</a>(I,ttmm1{q});
0047     ttmm1{q}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ttmm1{q}, n1, n2, m, r1, r2, n2);
0048     ttmm1{q}=permute(ttmm1{q}, [1 2 3 6 4 5]);
0049     ttmm1{q}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(ttmm1{q}, n1*n2, m*n2, r1, r2);
0050 <span class="comment">%     ttmm1{q} = zeros(n1*n2, m*n2, size(ttm1{q}, 3), size(ttm1{q}, 4));</span>
0051     
0052 <span class="comment">%     ttmm1{q}(1,1,:,:)=ttm1{q}(1,1,:,:);</span>
0053 <span class="comment">%     ttmm1{q}(2,1,:,:)=ttm1{q}(1,2,:,:);</span>
0054 <span class="comment">%     ttmm1{q}(1,2,:,:)=ttm1{q}(2,1,:,:);</span>
0055 <span class="comment">%     ttmm1{q}(2,2,:,:)=ttm1{q}(2,2,:,:);</span>
0056 <span class="comment">%</span>
0057 <span class="comment">%     ttmm1{q}(3,3,:,:)=ttm1{q}(1,1,:,:);</span>
0058 <span class="comment">%     ttmm1{q}(4,3,:,:)=ttm1{q}(1,2,:,:);</span>
0059 <span class="comment">%     ttmm1{q}(3,4,:,:)=ttm1{q}(2,1,:,:);</span>
0060 <span class="comment">%     ttmm1{q}(4,4,:,:)=ttm1{q}(2,2,:,:);</span>
0061 <span class="keyword">end</span>;
0062 
0063 ttmm2 = <a href="../../tt2/core/tt_mat_to_vec.html" class="code" title="function [tt_vec]=tt_mat_to_vec(tt_mat)">tt_mat_to_vec</a>(ttm2);
0064 
0065 <span class="keyword">if</span> (exists_max_r)
0066     <span class="keyword">if</span> (exists_max_swp)
0067         ttm12 = <a href="../../tt2/core/tt_mvk2.html" class="code" title="function [y,swp]=tt_mvk2(a,x,eps, max_r, max_swp)">tt_mvk2</a>(ttmm1, ttmm2, eps, max_r, max_swp);
0068     <span class="keyword">else</span>
0069         ttm12 = <a href="../../tt2/core/tt_mvk2.html" class="code" title="function [y,swp]=tt_mvk2(a,x,eps, max_r, max_swp)">tt_mvk2</a>(ttmm1, ttmm2, eps, max_r);
0070     <span class="keyword">end</span>;
0071 <span class="keyword">else</span>
0072     <span class="keyword">if</span> (exists_max_swp)
0073         ttm12 = <a href="../../tt2/core/tt_mvk2.html" class="code" title="function [y,swp]=tt_mvk2(a,x,eps, max_r, max_swp)">tt_mvk2</a>(ttmm1, ttmm2, eps, [], max_swp);
0074     <span class="keyword">else</span>
0075         ttm12 = <a href="../../tt2/core/tt_mvk2.html" class="code" title="function [y,swp]=tt_mvk2(a,x,eps, max_r, max_swp)">tt_mvk2</a>(ttmm1, ttmm2, eps);
0076     <span class="keyword">end</span>;
0077 <span class="keyword">end</span>;
0078 
0079 ttm12 = <a href="../../tt2/core/tt_vec_to_mat.html" class="code" title="function [tt_mat]=tt_vec_to_mat(tt_vec,n,m)">tt_vec_to_mat</a>(ttm12, ns1, ns2);
0080 
0081 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>